package com.example.guideapp.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.guideapp.R;
import com.example.guideapp.bean.WishTypeMessage;

import java.util.List;

/**
 * Created by Administrator on 2017/10/18.
 */

public class MyChooseWishMsgAdapter extends BaseAdapter {

    private Context context;
    private List<WishTypeMessage> list;

    private LayoutInflater mInflater;

    public MyChooseWishMsgAdapter(Context context, List<WishTypeMessage> list) {
        this.context = context;
        this.list = list;

        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        WishTypeMessageViewHolder viewHolder;
        if (convertView == null){
            convertView = mInflater.inflate(R.layout.choose_msg_item,null);
            viewHolder = new WishTypeMessageViewHolder();
            viewHolder.tv_content = (TextView) convertView.findViewById(R.id.tv_choose_content);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (WishTypeMessageViewHolder) convertView.getTag();
        }
        viewHolder.tv_content.setText(list.get(position).getContent());

        return convertView;
    }

    class WishTypeMessageViewHolder{
        private TextView tv_content;
    }
}
